﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Model;
using System.Collections.Generic;

namespace Control
{
    /// <summary>
    /// RioCMS CRUD para Templates
    /// </summary>
    [WebService(
        Name = "TemplatesServices",
        Description = "RioCMS CRUD para Templates",
        Namespace = "RioCMSControl"
    )]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class TemplatesServices : System.Web.Services.WebService
    {
        private MGTemplates mg = new MGTemplates();

        [WebMethod(Description = "Retorna uma lista com todos os templates")]
        public List<Template> listar()
        {
            if (!this.mg.autenticar())
                return null;
            else
                return this.mg.listar();
        }

        [WebMethod(Description = "Adicona um novo template")]
        public bool? adicionar(String nome, String arquivo)
        {
            if (!this.mg.autenticar())
                return null;
            else
                return this.mg.adicionar(nome, arquivo);
        }
        [WebMethod(Description = "Remove um template")]
        public bool? remover(uint id)
        {
            if (!this.mg.autenticar())
                return null;
            else
                return this.mg.remover(id);
        }

    }
}
